define([
    'base',
    'bootstrapDialog',
    'bootstrapTable',
    'highcharts',
    'exporting',
    'highchartsCN',
    'jqViewer',
    'jqPrint',
    "css!global/plugins/viewer/viewer.min.css"
], function (base, BootstrapDialog, highcharts, jqPrint) {
    //默认加载基础库
    base();
    const companyStatus = ['未提交', '待认领', '办理中', '退回修改', '审核通过', '取消办理'];

    /**
     * 生成highcharts
     * @param title
     * @param nodeName
     * @param data
     */
    function getCharts(title, nodeName, data) {
        Highcharts.chart(nodeName, {
            title: {
                text: title + "报表统计"
            },
            xAxis: {
                categories: companyStatus
            },
            yAxis: {
                allowDecimals: false,
                title: {
                    text: '数量（件）'
                }
            },
            series: [{
                type: 'column',
                name: '数量',
                colorByPoint: true,
                data: data,
                showInLegend: false
            }]
        });
    }


    return {
        all: function (nodeName,titleList,allCountList,successCountList,processCountList) {
           // getCharts('综合', nodeName, data);

            Highcharts.chart(nodeName,{
                chart: {
                    type: 'column'
                },
                title: {
                    text: '办理事项报表'
                },
                xAxis: {
                    categories: titleList,
                    crosshair: true
                },
                yAxis: {
                    min: 0,
                    title: {
                        text: '事项 (件)'
                    }
                },
                tooltip: {
                    // head + 每个 point + footer 拼接成完整的 table
                    headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
                    pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
                    '<td style="padding:0"><b>{point.y} 件</b></td></tr>',
                    footerFormat: '</table>',
                    shared: true,
                    useHTML: true
                },
                plotOptions: {
                    column: {
                        borderWidth: 0
                    }
                },
                series: [{
                    name: '已完结',
                    data: successCountList
                }, {
                    name: '办理中',
                    data: processCountList
                }, {
                    name: '总数量',
                    data:allCountList
                }]
            });


        },
        as: function (nodeName,titleList,allCountList,successCountList,receiveCountList,backCountList,acceptedCountList) {
            Highcharts.chart(nodeName,{
                chart: {
                    type: 'column'
                },
                title: {
                    text: '部门办件报表'
                },
                xAxis: {
                    categories: titleList,
                    crosshair: true
                },
                yAxis: {
                    min: 0,
                    title: {
                        text: '事项 (件)'
                    }
                },
                tooltip: {
                    // head + 每个 point + footer 拼接成完整的 table
                    headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
                    pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
                        '<td style="padding:0"><b>{point.y} 件</b></td></tr>',
                    footerFormat: '</table>',
                    shared: true,
                    useHTML: true
                },
                plotOptions: {
                    column: {
                        borderWidth: 0
                    }
                },
                series: [{
                    name: '办理完结',
                    data: successCountList
                }, {
                    name: '办理中',
                    data: acceptedCountList
                }, {
                    name: '收件',
                    data: receiveCountList
                },{
                    name: '退件',
                    data: backCountList
                },
                    {
                        name: '总数量',
                        data:allCountList
                    }
                ]
            });


        },
        item: function (itemList) {
            $.each(itemList, function (k, v) {
                console.log(k, v);
                //getCharts(title, 'allBox', data);
            });

        }


    };
});






